home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Integers / Integers.h < prev    next >
Text File  |  1997-06-28  |  2KB  |  66 lines

  1. // Integers.h
  2.  
  3. #ifndef Integers_h
  4. #define Integers_h
  5.  
  6. typedef char int8;
  7. enum { minint8 = -0x80, maxint8 = 0x7f };
  8.  
  9. typedef unsigned char uint8;
  10. enum { maxuint8 = 0xff };
  11.  
  12. typedef short int16;
  13. enum { minint16 = -0x8000, maxint16 = 0x7fff };
  14.  
  15. typedef unsigned short uint16;
  16. enum { maxuint16 = 0xffff };
  17.  
  18. typedef long int32;
  19. enum { minint32 = -0x7fffffff-1, maxint32 = 0x7fffffff };
  20.  
  21. typedef unsigned long uint32;
  22. enum { maxuint32 = 0xffffffff };
  23.  
  24. typedef long long int64;
  25. typedef unsigned long long uint64;
  26.  
  27. inline uint8 Byte0( uint16 x )        { return ( x       ) & 0xff; }
  28. inline uint8 Byte1( uint16 x )        { return ( x >> 8  ) & 0xff; }
  29. inline uint8 Byte2( uint32 x )        { return ( x >> 16 ) & 0xff; }
  30. inline uint8 Byte3( uint32 x )        { return ( x >> 24 ) & 0xff; }
  31. inline uint8 Byte4( uint64 x )        { return ( x >> 32 ) & 0xff; }
  32. inline uint8 Byte5( uint64 x )        { return ( x >> 40 ) & 0xff; }
  33. inline uint8 Byte6( uint64 x )        { return ( x >> 48 ) & 0xff; }
  34. inline uint8 Byte7( uint64 x )        { return ( x >> 56 ) & 0xff; }
  35.  
  36. inline uint16 Word0( uint32 x )        { return ( x       ) & 0xffff; }
  37. inline uint16 Word1( uint32 x )        { return ( x >> 16 ) & 0xffff; }
  38. inline uint16 Word2( uint64 x )        { return ( x >> 32 ) & 0xffff; }
  39. inline uint16 Word3( uint64 x )        { return ( x >> 48 ) & 0xffff; }
  40.  
  41. bool CanAdd( uint8 a, uint8 b );
  42. bool CanAdd( uint16 a, uint16 b );
  43. bool CanAdd( uint32 a, uint32 b );
  44.  
  45. bool CanAdd( int8 a, int8 b );
  46. bool CanAdd( int16 a, int16 b );
  47. bool CanAdd( int32 a, int32 b );
  48.  
  49. bool CanSubtract( uint8 a, uint8 b );
  50. bool CanSubtract( uint16 a, uint16 b );
  51. bool CanSubtract( uint32 a, uint32 b );
  52.  
  53. bool CanSubtract( int8 a, int8 b );
  54. bool CanSubtract( int16 a, int16 b );
  55. bool CanSubtract( int32 a, int32 b );
  56.  
  57. bool CanMultiply( uint8 a, uint8 b );
  58. bool CanMultiply( uint16 a, uint16 b );
  59. bool CanMultiply( uint32 a, uint32 b );
  60.  
  61. bool CanMultiply( int8 a, int8 b );
  62. bool CanMultiply( int16 a, int16 b );
  63. bool CanMultiply( int32 a, int32 b );
  64.  
  65. #endif
  66.